//
// Description: 507. 完美数
// Created by Loading on 2021/12/31.
//

#include <bits/stdc++.h>

using namespace std;

bool checkPerfectNumber(int num) {
    if (num == 1) {
        return false;
    }

    int sum = 1;
    // 最多循环到 sqrt(num)
    for (int d = 2; d * d <= num; ++d) {
        if (num % d == 0) {
            sum += d;
            if (d * d < num) {
                sum += num / d;
            }
        }
    }
    return sum == num;

    /* 数学 */
//    return num == 6 || num == 28 || num == 496 || num == 8128 || num == 33550336;
}

int main() {
    int num = 55868686;
    bool res = checkPerfectNumber(num);
    cout << res << endl;

    return 0;
}